package com.ruoyi.project.system.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.system.domain.SysAlarm;
import com.ruoyi.project.system.service.ISysAlarmService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 报警记录Controller
 * 
 * @author jjp
 * @date 2020-03-30
 */
@RestController
@RequestMapping("/system/alarm")
public class SysAlarmController extends BaseController
{
    @Autowired
    private ISysAlarmService sysAlarmService;

    /**
     * 查询报警记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:alarm:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysAlarm sysAlarm)
    {
        startPage();
        List<SysAlarm> list = sysAlarmService.selectSysAlarmList(sysAlarm);
        return getDataTable(list);
    }

//    /**
//     * 获取报警记录详细信息
//     */
//    @PreAuthorize("@ss.hasPermi('system:alarm:query')")
//    @GetMapping(value = "/{alarmId}")
//    public AjaxResult getInfo(@PathVariable("alarmId") Long alarmId)
//    {
//        return AjaxResult.success(sysAlarmService.selectSysAlarmById(alarmId));
//    }

    /**
     * 新增报警记录
     */
    @PreAuthorize("@ss.hasPermi('system:alarm:add')")
    @Log(title = "报警记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysAlarm sysAlarm)
    {
        return toAjax(sysAlarmService.insertSysAlarm(sysAlarm));
    }

    /**
     * 修改报警记录
     */
    @PreAuthorize("@ss.hasPermi('system:alarm:edit')")
    @Log(title = "报警记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysAlarm sysAlarm)
    {
        return toAjax(sysAlarmService.updateSysAlarm(sysAlarm));
    }

    /**
     * 删除报警记录
     */
    @PreAuthorize("@ss.hasPermi('system:alarm:remove')")
    @Log(title = "报警记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{alarmIds}")
    public AjaxResult remove(@PathVariable Long[] alarmIds)
    {
        return toAjax(sysAlarmService.deleteSysAlarmByIds(alarmIds));
    }
}
